﻿using JGSY.NotNetty.ControllerBus;
using JGSY.NotNetty.ControllerBus.Models;

namespace JGSY.DotNetty.Controlers
{
    public class TestController : BaseController
    {
        public ResultModel Test01()
        {
            return ResultModel.Success("同步测试成功");
        }
        public async Task<ResultModel> Test02()
        {
            return await Task.Run(() => ResultModel.Success("异步测试成功"));
        }
        public ResultModel Test03(string name)
        {
            return ResultModel.Success($"同步测试成功:{name}");
        }
        public async Task<ResultModel> Test04(string name)
        {
            return await Task.Run(() => ResultModel.Success($"异步测试成功:{name}"));
        }
        public ResultModel Test05(TestRequestModel requestModel)
        {
            return ResultModel.Success($"同步测试成功:{requestModel.Name},{requestModel.Age}");
        }
        public async Task<ResultModel> Test06(TestRequestModel requestModel)
        {
            return await Task.Run(() => ResultModel.Success($"异步测试成功:{requestModel.Name},{requestModel.Age}"));
        }
        public string Test07()
        {
            return "同步测试成功";
        }
        public async Task<string> Test08()
        {
            return await Task.Run(() => "异步测试成功");
        }
        public int Test09()
        {
            return 200;
        }
        public async Task<int> Test10()
        {
            return await Task.Run(() => 400);
        }
        public Stream Test11()
        {
            string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MIMEConfig.json");
            FileStream fileStream = File.OpenRead(configFilePath);
            return fileStream;
        }
        public async Task<Stream> Test12()
        {
            return await Task.Run(() =>
            {
                string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MIMEConfig.json");
                FileStream fileStream = File.OpenRead(configFilePath);
                return fileStream;
            });
        }
    }
    public class TestRequestModel
    {
        public string Name { get; set; }

        public int Age { get; set; }
    }
}